<?php
require_once(dirname(dirname(__FILE__)) . '/app.php');

need_login();

$condition = array(
			'user_id' => $login_user_id,
			'team_id > 0',
			'state'	=> 'unpay' );
$unpay_count = Table::Count('order', $condition);


$condition_mobile = array(
		'enable' => 'Y',
		'user_id' => $login_user_id,
);
$havemobile = DB::GetTableRow ('toolsbind', $condition_mobile);



$daytime = strtotime(date('Y-m-d'));
$coupon_condition = array(
		'user_id' => $login_user_id,
		'consume' => 'N',
		"expire_time >= {$daytime}",
);

$unconsume_count = Table::Count('coupon', $coupon_condition);
list($pagesize, $offset, $pagestring) = pagestring($count, 10);
$coupons = DB::LimitQuery('coupon', array(
		'condition' => $coupon_condition,
		'order' => 'ORDER BY team_id DESC, create_time DESC',
		'size' => $pagesize,
		'offset' => $offset,
));

$team_ids = Utility::GetColumn($coupons, 'team_id');
$teams = Table::Fetch('team', $team_ids);

$pagetitle = '用户中心';
include template('account_index');
